var img1 = document.getElementById('img1');

img1.ontouchstart = function(e) {
    e.preventDefault();
    var startX = e.originalEvent.changedTouches[0].pageX,
    startY = e.originalEvent.changedTouches[0].pageY;
};
img1.ontouchmove = function(e) {
    e.preventDefault();
    var moveEndX = e.originalEvent.changedTouches[0].pageX,
        moveEndY = e.originalEvent.changedTouches[0].pageY,
        X = moveEndX - startX,
        Y = moveEndY - startY;

    if ( X > 0 ) {
        alert("left 2 right");
    }
    else if ( X < 0 ) {
        alert("right 2 left");
    }
    else if ( Y > 0) {
        alert("top 2 bottom");
    }
    else if ( Y < 0 ) {
        alert("bottom 2 top");
    }
    else{
        alert("just touch");
    }
};